<?php
   	include_once('class/autoload.php');  
   	include_once 'class/MyPDO.php';
   	$titre="Inscription membre";
   	$site = new page_base('Acceuil connexion');
   	$site->titre = "connexion USEP";
 	if(!isset($_COOKIE["PHPSESSID"]))
   	{
    $site->corps = "
    		<h1> Connexion </h1>
<form method='post' action='inscriptionutilisateur.php'>

	<label for='nom'>Nom</label>
	<input type='text' name='nom' id='nom' value=''/>

	<label for='prenom'>Pr�nom</label>
	<input type='text' name='prenom' id='prenom' value=''/>

	<label for='email'>Adresse email</label>
	<input type='text' name='email' id='email' value=''/>

	<label for='passe'>Mot de passe</label>
	<input type='password' name='pass' id='pass' value=''/>



	<input type='submit' name='envoi' value='Envoyer'/>

</form>

    		";
   	}
   	else 
   	{
   		$site->corps = "deja connecter";
   	}

   	if(isset($_POST) && isset($_POST['nom']) && isset($_POST['prenom'])
 && isset($_POST['email']) && isset($_POST['pass'])){
   		$id_membre = '';
		$nom = $_POST['nom'];
		$prenom = $_POST['prenom'];
		$email = $_POST['email'];
		$salt = "48@!alsd";
		$password = $_POST['pass'];
		$password_crypte = sha1(sha1($password).$salt);
		$i = $bdd->prepare("
			INSERT INTO membres (id_membre,nom,prenom,email,mot_passe)
			VALUES (:id_membre,:nom,:prenom,:email,:mot_passe)");
		$i->execute(array(
				'id_membre' => $id_membre ,
				'nom' => $nom ,
				'prenom' =>  $prenom ,
				'email' =>  $email ,
				'mot_passe' => $password_crypte));
		
		echo 'insertion reussi';
    	}
    else 
    {
    	echo 'Non reussi';
    }
    

    $site->affiche();
   			
?>